import threading
import  time

lock = threading.Lock()
num = 100

def func1():
    for i in range(200):
        global  num
        if num > 0:
            lock.acquire()
            print(threading.current_thread().getName()+"正在输出：",num)
            num -= 1
            lock.release()
            time.sleep(0.5)
def func2():
    for i in range(200):
        global num
        if num >0:
            lock.acquire()
            print(threading.current_thread().getName()+"正在输出：",num)
            num -= 1
            lock.release()
            time.sleep(0.5)

def func3():
                for i in range(200):
                    global num
                    if num > 0:
                        lock.acquire()
                        print(threading.current_thread().getName() + "正在输出：", num)
                        num -= 1
                        lock.release()
                        time.sleep(0.5)

def start():
    t1 = threading.Thread(target=func1)
    t1.start()
    t2 = threading.Thread(target=func2)
    t2.start()
    t3 = threading.Thread(target=func3)
    t3.start()

if __name__ == '__main__':
    start()